package com.sky.mapper;

import com.sky.AutoFIle.AutoFiles;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /**
     * 根据 id来查找套餐 展示VO
     * @param id
     * @return
     */
    @Select("select s.*,c.name categoryName from setmeal s left outer join category c on s.category_id=c.id where s.id=#{id}")
    SetmealVO SelectByid(Long id);

    /**
     * 新增套餐
     * @param setmeal
     */
    @AutoFiles(OperationType.INSERT)
    void sava(Setmeal setmeal);

    /**
     * 根据ID来批量删除
     * @param ids
     */
    void SelectSetmealId(List<Long> ids);

    /**
     * 修改套餐信息
     * @param setmeal
     */
    @AutoFiles(OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 分页查询
     * @param queryDTO
     * @return
     */
    List<SetmealVO> pagelist(SetmealPageQueryDTO queryDTO);

    /**
     * 根据分类来查询套餐
     * @param categoryId
     * @return
     */
    @Select("select * from setmeal where category_id=#{categoryId} and status=1")
    List<Setmeal> selectByCategoryId(Long categoryId);
}
